package com.github.cooingandwooing.common.core.utils;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * 〈错误码相关方法〉
 *
 * @author Administrator
 * @create 2022/4/26
 * @since 1.0.0
 */
public class ErrorCodeUtils {
    /**
     * 获得错误码对应的提示信息
     * @param errcode 错误码
     * @param params 匹配参数
     * @return 返回错误提示信息
     */
    public static String getMessage(String errcode, String ...params){
        ResourceBundle bundle = ResourceBundle.getBundle("i18n/messages", Locale.getDefault());
        String msg = bundle.getString(errcode);
        MessageFormat messageFormat = new MessageFormat(msg);
        return messageFormat.format(params);
    }
}
